package com.ewhale.feitengguest.presenter.user.mine;

import com.ewhale.feitengguest.api.ApiHelper;
import com.ewhale.feitengguest.view.user.mine.ResetPasswordView;
import com.simga.library.base.IPresenter;
import com.simga.library.http.APIException;

public class ResetPasswordPresenter extends IPresenter {
    String user_reset_passowrk = "app/account/updatePassword.json";
    String shop_reset_passowrk = "app/shop/updatePassword.json";
    public void resetPassword(int apptype,String oldPwd, String newPwd1, String newPwd2, String token) {
        mView.showProLoading();
        request(1, ApiHelper.AUTH_API.resetPassword(apptype == 0 ? user_reset_passowrk : shop_reset_passowrk,oldPwd, newPwd1,newPwd2, token), null);
    }
    @Override
    public <T> void onNext(int postCode, T result, Object data) {
        super.onNext(postCode, result, data);
        switch (postCode) {
            case 1:
                ((ResetPasswordView) mView).resetSuccess();
                break;
        }
    }

    @Override
    public void otherException(int postCode, Object data, APIException e) {
        super.otherException(postCode, data, e);
        mView.showErrorMessage(postCode, e.getCode(), e.getDisplayMessage());
    }
}
